// 可控制的现在时间
package nowctrl

import (
	"sync"
	"time"
)

func Now() int {
	var now int
	switch nowMode {
	case 1:
		now = nowTime
	default:
		now = int(time.Now().Unix())
	}
	return now
}

// 0-真实时间 1-虚拟时间
func SetMode(val int) {
	nowMode = val
}
func SetNow(val int) {
	nowTime = val
}
func Increase(val int) int {
	nowSync.Lock()
	nowTime = nowTime + val
	nowSync.Unlock()
	return nowTime
}

var (
	nowMode int
	nowTime int
	nowSync sync.Mutex
)
